
import router, { VarRoutes, constantRoutes } from '@/router'
export default {
  namespaced: true,
  state: {
    allRoutesRules: [],
    points: {
      // 员工页面的权限标识
      pointUserUpdate: 'POINT-USER-UPDATE',
      pointUserEdit: 'point-user-edit',
      pointUserDelete: 'point-user-delete',
      pointUserSetJob: 'point-user-setjob',

      // 权限页面的权限标识
      pointPermissionAdd: 'point-permission-add',
      pointPermissionDelete: 'point-permission-delete'
    }
  },
  mutations: {
    setFilterVarRoutes(state, payload) {
      const filterVarRoutes = VarRoutes.filter(item => payload.menus.includes(item.name)) // 根据权限筛选出路由规则
      const route404 = { path: '*', redirect: '/404', hidden: true }
      router.addRoutes([...filterVarRoutes, route404]) // 动态添加路由规则
      state.allRoutesRules = [...constantRoutes, ...filterVarRoutes, route404] // 保存在vuex中
    }
  },
  actions: {
  }
}

